package com.nowar.interceptor;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.AbstractClientHttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Author: 谢无殇。
 * @Date : 2024-06-30 14:30
 */
@Component
public class NowarClientHttpRequestInterceptor implements ClientHttpRequestInterceptor {
    @Override
    public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
        AbstractClientHttpRequest clientHttpRequest = (AbstractClientHttpRequest) request;
        HttpHeaders headers = clientHttpRequest.getHeaders();
        System.out.println(headers);
        System.out.println(String.valueOf(body));
        return execution.execute(request, body);
    }
}
